<?php

/**
 *      [Discuz!] (C)2001-2099 Comsenz Inc.
 *      This is NOT a freeware, use is subject to license terms
 *
 *      $Id: magic_up.php 6752 2010-03-25 08:47:54Z cnteacher $
 */

if(!defined('IN_DISCUZ')) {
	exit('Access Denied');
}

if(submitcheck('usesubmit')) {

	if(empty($_G['tid'])) {
		showmessage('magics_info_nonexistence');
	}

	$thread = getpostinfo($_G['tid'], 'tid', array('fid'));
	checkmagicperm($magicperm['forum'], $thread['fid']);

	DB::query("UPDATE ".DB::table('forum_thread')." SET lastpost='$_G[timestamp]', moderated='1' WHERE tid='$_G[tid]'");

	usemagic($magicid, $magic['num']);
	updatemagiclog($magicid, '2', '1', '0', $_G['tid']);
	updatemagicthreadlog($_G['tid'], $magicid, $magic['identifier']);

	if($thread['authorid'] != $_G['uid']) {
		sendnotice($thread['authorid'], 'magic_thread', 'systempm');
	}

	showmessage('magics_operation_succeed');

}

function showmagic() {
	global $_G, $lang;
	magicshowtype($lang['option'], 'top');
	magicshowsetting($lang['target_tid'], 'tid', $_G['tid'], 'text');
	magicshowtype('', 'bottom');
}

?>